<?

if($_REQUEST["action"]=="recherche"){
	$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."wowheaditem where nom like '%".$_REQUEST["str"]."%' and slot in (1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,21,25,28) order by nom");
	foreach($res as $var){
		echo wishlist_getItemContainer($var->idItem);
	}
}

if($_REQUEST["action"]=="get item"){
	echo wishlist_getItemContainer($_REQUEST["itemId"]);
}

if($_REQUEST["action"]=="ajouter_item"){
	$var=$sql->request_single("select * from ".CFG_MYSQL_PREFIX."wishlist_item where idPlayer=".$_REQUEST["idPlayer"]." and slot='".$_REQUEST["slot"]."' and n=".$_REQUEST["n"]);
	if($var===false){
		$sql->query("insert into ".CFG_MYSQL_PREFIX."wishlist_item(idPlayer, idItem, slot, n) values(".$_REQUEST["idPlayer"].",".substr($_REQUEST["idItem"],4).",'".$_REQUEST["slot"]."',".$_REQUEST["n"].")");
	}else{
		$sql->query("update ".CFG_MYSQL_PREFIX."wishlist_item set idItem=".substr($_REQUEST["idItem"],4)." where  idPlayer=".$_REQUEST["idPlayer"]." and slot='".$_REQUEST["slot"]."' and n=".$_REQUEST["n"]);
	}
}

if($_REQUEST["action"]=="enlever_item"){
	$sql->query("delete from ".CFG_MYSQL_PREFIX."wishlist_item where  idPlayer=".$_REQUEST["idPlayer"]." and slot='".$_REQUEST["slot"]."' and n=".$_REQUEST["n"]);
}
